const twoSum1 = function (numbers, target) {
  let nums = []
  for (let i = 0; i < numbers.length; i++) {
    let temp = target - numbers[i]
    if (nums.includes(temp)) {
      return [numbers.indexOf(temp) + 1, i + 1]
    }
    if (!nums.includes(numbers[i])) {
      nums.push(numbers[i])
    }
  }
  return []
}

const twoSum2 = function (numbers, target) {
  let left = 0
  let right = numbers.length - 1
  while (left < right) {
    if (numbers[left] + numbers[right] === target) {
      return [left + 1, right + 1]
    } else if (numbers[left] + numbers[right] < target) {
      left++
    } else {
      right--
    }
  }
  return []
}

const numbers = [-1, 0]

const res = twoSum1(numbers, -1)
console.log1(res)
